﻿using System;
using System.Collections.Generic;
using Budgetsch.Web.EntityModel;
using Budgetsch.Web.Services;
using GalaSoft.MvvmLight;

namespace Budgetsch.ViewModels.Savings
{
    public abstract class SavingDetailVMBase : ViewModelBase
    {
        protected readonly BudgetschDomainContext m_context;

        public IEnumerable<SavingCategory> Categories { get; set; }

        private Saving m_Saving;
        public const string NewSavingPropertyName = "Saving";
        public Saving Saving
        {
            get
            {
                return m_Saving;
            }

            set
            {
                if (m_Saving == value)
                {
                    return;
                }

                m_Saving = value;
                RaisePropertyChanged(() => Saving);
            }
        }

        protected SavingDetailVMBase(BudgetschDomainContext context_)
        {
            m_context = context_;
            m_context.Load(m_context.GetSavingCategoriesWithItemsQuery());
            Categories = m_context.SavingCategories;
        }

        public abstract void Commit();
    }
}